import EventEmitter from './EventEmitter.js'

export function extend(constructorFn, methods) {
  class Extended extends EventEmitter {
    constructor(...args) {
      super()
      constructorFn.apply(this, args)
    }
  }

  if (methods && typeof methods === 'object') {
    Object.keys(methods).forEach((key) => {
      Extended.prototype[key] = methods[key]
    })
  }

  return Extended
}

export default {
  extend,
}
